package net.m510.autosurfer.sonybank;

import java.net.URI;
import java.util.List;
import java.util.logging.Logger;

import net.m510.autosurfer.common.DocumentPostProcess;
import net.m510.autosurfer.core.Parameters;
import net.m510.autosurfer.core.utils.AnalyzeUtils;

import org.apache.http.NameValuePair;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.impl.client.CloseableHttpClient;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.FormElement;

public class SonyBankLogin extends DocumentPostProcess {
	private static final Logger log = Logger.getLogger(SonyBankLogin.class.getName());
	private String tenNo;
	private String kozaNo;
	private String password;
	
	private String cid;
	private String tid;
	private String zid;

	public SonyBankLogin() {
		this(null,null);
	}
	public SonyBankLogin(CloseableHttpClient client, HttpClientContext context) {
		super(client, context);
		super.log = log;
	}
	@Override
	protected URI getUri(Document doc) {
		FormElement form = doc.getAllElements().forms().get(0);
		return AnalyzeUtils.resolveURIByFormAction(context, form);
	}
	
	@Override
	protected List<NameValuePair> getRequestParameters(Document doc) {
		FormElement form = doc.getAllElements().forms().get(0);
		Parameters p = Parameters.create(form);
		p.put("__type", "0003");
		p.put("__fid", "NBP000109");
		p.put("__gid", "NBP000109G01");
		p.put("B_ID", "1");
		p.put("__uid", kozaNo);
		p.put("TenNo", tenNo);
		p.put("KozaNo", kozaNo);
		p.put("Password", password);
		p.put("CookieId", cid);
		p.put("TanmatsuShubt", tid);
		p.put("ZenkaiLogonTime", zid);
		
		return p.asNameValueList();
	}
	public String getTenNo() {
		return tenNo;
	}
	public void setTenNo(String tenNo) {
		this.tenNo = tenNo;
	}
	public String getKozaNo() {
		return kozaNo;
	}
	public void setKozaNo(String kozaNo) {
		this.kozaNo = kozaNo;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getCid() {
		return cid;
	}
	public void setCid(String cid) {
		this.cid = cid;
	}
	public String getTid() {
		return tid;
	}
	public void setTid(String tid) {
		this.tid = tid;
	}
	public String getZid() {
		return zid;
	}
	public void setZid(String zid) {
		this.zid = zid;
	}

}